package com.schmix.dpp;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

public class CalculateNeedsTabActivity extends TabActivity {

	private TabHost tabHost;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.calc_needs_tabs);

		tabHost = getTabHost(); // The activity TabHost
		initTab(new TextView(this), "info", "Info", CalculateNeedsInfoActivity.class);
		initTab(new TextView(this), "goalweight", "Goal Weight Rec.", CalculateNeedsActivity.class);
		initTab(new TextView(this), "usdh", "Dept. of Health Rec.", USDeptHealthNeedsActivity.class);

		tabHost.setCurrentTab(0);
	}
	
	private void initTab(final View view, String tag, String title, Class<?> clazz){
		View tabView = getTabView(this, title);
		TabSpec spec = tabHost.newTabSpec(tag).setIndicator(tabView).setContent(new Intent().setClass(this, clazz));
		tabHost.addTab(spec);
	}
	
	private static View getTabView(final Context context, final String title){
		View view = LayoutInflater.from(context).inflate(R.layout.tab_layout, null);
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		tv.setText(title);
		return view;
	}

}
